package com.tinem.platform.module.starter.token.config;

import com.alibaba.fastjson.JSONObject;
import com.tinem.platform.module.starter.token.TokenUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Date;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author fzh
 * @version v1
 * @program: platform
 * @className JmsConfiguration
 * @description
 * @site
 * @company
 * @create 2021-11-08 14:10
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "token")
public class TokenConfiguration {

    List<Config> config;

    @Data
    public static class Config{
        String clientId;
        /**
         * 授权地址
         */
        String authUrl;

        final java.util.concurrent.locks.ReentrantLock tokenLock = new ReentrantLock();

        JSONObject token;

        Date tokenExpires;
    }
    @Bean
    public TokenUtil tokenUtil(){
        return new TokenUtil(config);
    }
}
